﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Restaurants.aspx.cs" Inherits="WTSTC_App.Restaurants" %>

<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
        <h2>Restaurant Search</h2>
        <p>
            <asp:Button ID="locAndNameButton" runat="server" 
                onclick="locAndNameButton_Click" Text="Search by Location &amp; Name" 
                Width="280px" Height="25px" />
        <asp:DropDownList ID="stateDropDownList" runat="server" Enabled="True" 
            Height="20px" Width="130px" 
            CssClass="dropdown" DataSourceID="SqlDataSource1" DataTextField="State" 
            DataValueField="State" AutoPostBack="True"></asp:DropDownList>
        <asp:DropDownList ID="cityDropDownList" runat="server" Enabled="True" 
            Height="20px" Width="147px" 
            CssClass="dropdown" DataTextField="City"
            DataSourceID="SqlDataSource2" AutoPostBack="True"></asp:DropDownList>
        <asp:DropDownList ID="nameDropDownList" runat="server" Height="20px" Width="169px" 
            CssClass="dropdown" DataSourceID="SqlDataSource3" DataTextField="Name" 
            DataValueField="Name" AutoPostBack="True"></asp:DropDownList>
        </p>
        <br />
        <br />
        <asp:Button ID="phoneButton" runat="server" onclick="phoneButton_Click" 
            Text="Search by Phone Number" Width="280px" Height="25px" />
        <asp:DropDownList ID="phoneDropDownList" runat="server" CssClass="dropdown" 
            DataSourceID="SqlDataSource4" DataTextField="Phone" DataValueField="Phone" 
            Height="20px" Visible="False" Width="130px">
        </asp:DropDownList>
        <br />
        <br />
        <br />
        <br />
        <asp:Button ID="storeNumButton" runat="server" onclick="storeNumButton_Click" 
            Text="Search by Store Number" Width="280px" Height="25px" />
        <asp:DropDownList ID="storeNumDropDownList" runat="server" CssClass="dropdown" 
            Height="20px" Visible="False" Width="130px" DataSourceID="SqlDataSource5" 
            DataTextField="Store Number" DataValueField="Store Number">
        </asp:DropDownList>
        <br />
        <br />
        <br />
        <br />
        <asp:Button ID="addNewResButton" runat="server"
            Text="Add New Restaurant" Width="280px" onclick="addNewResButton_Click" 
            Height="25px" />
        <br />
        <br />
        <asp:Label ID="cityLabel" runat="server" Text="CITY:" Visible="False" 
            Width="70px" Height="20px"></asp:Label>
        <asp:TextBox ID="CityTextBox" runat="server" Height="20px" MaxLength="25" 
            Visible="False"></asp:TextBox>
        <br />
        <asp:Label ID="stateLabel" runat="server" Text="ST:" Visible="False" 
            Width="70px" Height="20px"></asp:Label>
        <asp:TextBox ID="StateTextBox" runat="server" Height="20px" MaxLength="2" 
            Visible="False"></asp:TextBox>
        <br />
        <asp:Label ID="nameLabel" runat="server" Text="NAME:" Visible="False" 
            Width="70px" Height="20px"></asp:Label>
        <asp:TextBox ID="NameTextBox" runat="server" Height="20px" MaxLength="25" 
            Visible="False"></asp:TextBox>
        <br />
        <asp:Label ID="phoneLabel" runat="server" Text="PHONE:" Visible="False" 
            Width="70px" Height="20px"></asp:Label>
        <asp:TextBox ID="PhoneTextBox" runat="server" Height="20px" MaxLength="10" 
            Visible="False"></asp:TextBox>
        <br />
        <asp:Button ID="addButton" runat="server" onclick="addButton_Click" 
            Text="Add &gt;&gt;" Visible="False" Height="20px" />
        <asp:Label ID="addMessageLabel" runat="server" Height="20px"></asp:Label>
        <br />
        <br />
        <h2>
            Will They Split The Check?...</h2>
        <br />
        <asp:GridView ID="resultsGridView" runat="server" 
            onrowcommand="resultsGridView_RowCommand" CssClass="resultsGridView">
            <Columns>
                <asp:ButtonField ButtonType="Button" CommandName="IncrementNoVotes" 
                    HeaderText="Vote No" ShowHeader="True" Text="Vote No" />
                <asp:ButtonField ButtonType="Button" CommandName="IncrementYesVotes" 
                    HeaderText="Vote Yes" Text="Vote Yes" />
            </Columns>
        </asp:GridView>
        <h3>
        <asp:Label ID="voteLabel" runat="server" Visible="False"></asp:Label>
        </h3>
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:gnorris1ConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:gnorris1ConnectionString.ProviderName %>" 
            SelectCommand="SELECT State FROM RESTAURANT GROUP BY State">
        </asp:SqlDataSource>

        <!-- Gets all of the Cities for the State -->
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:gnorris1ConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:gnorris1ConnectionString.ProviderName %>" 
            SelectCommand="SELECT City FROM RESTAURANT WHERE (State = @theState) GROUP BY City" >
            <selectparameters>
              <asp:controlparameter name="theState" controlid="stateDropDownList" propertyname="SelectedValue"/>
          </selectparameters>
        </asp:SqlDataSource>

        <!-- Gets all of the Restaurants for the State & City -->
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
            ConnectionString="<%$ ConnectionStrings:gnorris1ConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:gnorris1ConnectionString.ProviderName %>" 
            
            SelectCommand="SELECT Name FROM RESTAURANT WHERE (State = @theState) AND (City = @theCity)" >
            <selectparameters>
              <asp:controlparameter name="theState" controlid="stateDropDownList" propertyname="SelectedValue"/>
              <asp:controlparameter name="theCity" controlid="cityDropDownList" propertyname="SelectedValue"/>
          </selectparameters>
        </asp:SqlDataSource>

        <!-- Gets all of the StoreNumbers -->
        <asp:SqlDataSource ID="SqlDataSource5" runat="server" 
            ConnectionString="<%$ ConnectionStrings:gnorris1ConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:gnorris1ConnectionString.ProviderName %>" 
            SelectCommand="SELECT `Store Number` FROM RESTAURANT">
        </asp:SqlDataSource>


        <!-- Gets all of the PhoneNumbers -->
        <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
            ConnectionString="<%$ ConnectionStrings:gnorris1ConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:gnorris1ConnectionString.ProviderName %>" 
            SelectCommand="SELECT `Phone` FROM RESTAURANT">
        </asp:SqlDataSource>
        <br />
    </asp:Content>
